package com.han.demo.springbootlistener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

/**
 * @author hanjl
 * @Description TODO
 * @ClassName MySpringService
 * @createTime 2021/11/18 9:50
 */
@Service
@Slf4j
public class MySpringService {

    @Autowired
    private ApplicationContext context;

    /**
     * 发布一个事件
     */
    public void doMySpringService(){
        log.info("MySpringService发起一个事件");
        context.publishEvent(new MySpringEvent(new Object()));
    }

}
